<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html,#allmap {
			width: 100%;
			height: 100%;
			overflow: hidden;
			margin:0;
			padding:0;
			font-family:"微软雅黑";
		}
		.BMap_cpyCtrl.BMap_noprint.anchorBL{
			display: none;
		}
		div.anchorBL>a>img{
			display: none;
		}
	</style>
	<script type="text/javascript" src="{$cfg.url}?v={$cfg.version}&ak={$cfg.ak}"></script>
	<title>逆地址解析</title>
</head>
<body>
	<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	var point = new BMap.Point(116.331398,39.897445);
	map.centerAndZoom('大理',10);
	var geoc = new BMap.Geocoder();

	map.addEventListener("click", function(e){
		var pt = e.point;
		geoc.getLocation(pt, function(rs){
			var addComp = rs.addressComponents;
			alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
		});
	});

	//	创建地址解析器实例
	var myGeo = new BMap.Geocoder();
	var addressList = [
		"祥云县彩云路",
		"弥渡县",
		"大理市",
		"宾川县",
		'大理市, 建设东路, 21号'
	];
	for(var i=0;i<addressList.length;i++){
		// 将地址解析结果显示在地图上
		myGeo.getPoint(addressList[i],function(point){
			if (point) {
				map.addOverlay(new BMap.Marker(point));
			}else{
				alert("您选择地址没有解析到结果!");
			}
		}, "大理市");
	}
</script>
